package stream.result;

import java.util.ArrayList;
import java.util.Collections;
import java.util.function.IntFunction;

public class Demo1 {
    public static void main(String[] args) {
        /**
         * stream的终结方法
         */
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "a", "b", "c");
        //forEach
        list.stream().forEach(s -> System.out.println(s));
        //count
        System.out.println(list.stream().count());
        //toArray
        String[] arr = list.stream().toArray(new IntFunction<String[]>() {
            @Override
            public String[] apply(int value) {
                return new String[value];
            }
        });
        for (String s : arr) {
            System.out.println(s);
        }

    }
}
